﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLy_NhaSach
{
    public partial class QuanlyKH : Form
    {
        public QuanlyKH()
        {
            InitializeComponent();
        }

        private void khachHangBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.khachHangBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.nhaSachDataSet);

        }

        private void QuanlyKH_Load(object sender, EventArgs e)
        {
            khachHangBindingSource.DataSource = NhaSachBUS.KhachHangBUS.LoadKhachHang();

        }

        private void them_Click(object sender, EventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                NhaSachBUS.KhachHangBUS.XoaKhachHang(int.Parse(maKHTextBox.Text));
                khachHangBindingSource.DataSource = NhaSachBUS.KhachHangBUS.LoadKhachHang();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            NhaSachBUS.KhachHangBUS.CapNhatKhachHang(int.Parse(maKHTextBox.Text), hoTenKHTextBox.Text, gioiTinhTextBox.Text, diaChiTextBox.Text, emailTextBox.Text, soDTTextBox.Text, soTaiKhoanTextBox.Text, int.Parse(soDiemTextBox.Text));
            khachHangBindingSource.DataSource = NhaSachBUS.KhachHangBUS.LoadKhachHang();
        }

        private void tabPage2_Click(object sender, EventArgs e)
        {

        }

        private void them_Click_1(object sender, EventArgs e)
        {
            NhaSachBUS.KhachHangBUS.ThemKhachHang( txttenkh.Text, txtgioitinh.Text, txtdiachi.Text, txtemail.Text, txtsdt.Text, txttaikhoan.Text, int.Parse(txtdiemtichluy.Text));
            khachHangBindingSource.DataSource = NhaSachBUS.KhachHangBUS.LoadKhachHang();
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            CloseForm();
        }
        public void CloseForm()
        {
            this.Dispose();
        }
    }
}
